﻿using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;

using Daybreak.Core.Rendering;

namespace Daybreak.Core.SceneGraph
{
    /// <summary>
    /// A Geode is a "geometry node", that is, a leaf node on the scene graph 
    /// that can have "renderable things" attached to it. 
    /// </summary>
    /// <remarks>
    /// All renderable things are represented by objects from the Drawable class, 
    /// so a Geode is a Node whose purpose is grouping Drawables. 
    /// </remarks>
    public class Geode : Node
    {
        protected List<Drawable.Container> _drawables = new List<Drawable.Container>();

        public Geode()
        {
        }

        public Geode(string name)
        {
            Name = name;
        }

        public override void ComputeBound(ref BoundingBox result)
        {
            for (int i = 0; i < _drawables.Count; i++)
            {
                _drawables[i].MergeBounding(ref result);
            }
        }

        public void AddDrawables(Drawable.Container geom)
        {
            _drawables.Add(geom);
        }

        public override void Accept(NodeVisitor visitor)
        {
            visitor.VisitGeode(this);
        }

        public override string ToString()
        {
            return "Geode drawables:" + _drawables.Count;
        }

        public List<Drawable.Container> Parts
        {
            get { return _drawables; }
        }
    }
}
